EasyPQC.Rotation

Rotation Class

The Rotation class is responsible for generating and rotating session keys, typically used to create a new session key by hashing a base key multiple times with salt for enhanced security.

Methods

CreateInitialKey(string key)

Generates an initial key and salt combination. The key is hashed using the ShakeDigest (SHAKE256) algorithm 1000 times along with a randomly generated salt. The resulting key and salt are returned as Base64-encoded strings.

  • Parameters:
    • key: The base key to be hashed (usually Base64-encoded).
  • Returns: Task<(string, string)>: A tuple containing the salt (Base64-encoded) and the generated key (Base64-encoded).

RotateKey(SecureData key, int rotations, string salt)

Rotates an existing key multiple times based on the number of rotations specified. Each rotation involves hashing the key and the salt using the ShakeDigest algorithm. After the specified number of rotations, the resulting key is returned as a Base64-encoded string.

  • Parameters:
    • key: The current session key, provided as a SecureData.
    • rotations: The number of times the key should be rotated (hashed).
    • salt: The salt used in the key rotation process.
  • Returns: Task: The rotated session key as a Base64-encoded string.

ToBase64(string input)

Converts an input string to a Base64-encoded string.

  • Parameters:
    • input: The string to be converted to Base64.
  • Returns: string: The Base64-encoded version of the input string.